home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / dev.fmt / pfs.man < prev    next >
Encoding:
Text File  |  1989-12-08  |  20.0 KB  |  465 lines

  1.  
  2.  
  3.  
  4. PFS                          Devices                          PFS
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NNAAMMEE
  11.      Pseudo-file-systems - File systems implemented by user-level
  12.      server processes.
  13.  
  14. _________________________________________________________________
  15.  
  16.  
  17. IINNTTRROODDUUCCTTIIOONN
  18.      A pseudo-file-system is a part of the distributed file  sys-
  19.      tem  that  is  implemented by a user-level server process as
  20.      opposed to parts of the file system that correspond to  real
  21.      disks  (local  or remote) controlled by Sprite kernels.  The
  22.      pseudo-file-system has its own prefix and  is  transparently
  23.      integrated  in  to  the  global  file hierarchy.  Files in a
  24.      pseudo-file-system are named and accessed with the same sys-
  25.      tem calls as regular files (or devices).
  26.  
  27.      This document describes the raw  kernel  interface  used  by
  28.      pseudo-file-system  servers.  The interface is a superset of
  29.      the pseudo-device interface that is described  in  the  ppddeevv
  30.      devices  man page.  There is also a PPffss library package that
  31.      takes care of most of the details of the interface and  pro-
  32.      vides an easy-to-use call-back interface.
  33.  
  34. RREEQQUUEESSTT--RREESSPPOONNSSEE SSTTRREEAAMMSS
  35.      The operating system  forwards  operations  on  the  pseudo-
  36.      file-system  up  to  the user-level server process using the
  37.      pseudo-device request response protocol.  This  protocol  is
  38.      described  in  detail in the ppddeevv man page.  When the server
  39.      starts up it gets a _n_a_m_i_n_g _s_t_r_e_a_m that is  used  to  forward
  40.      naming  operations like ooppeenn, rreemmoovvee, mmkkddiirr, and rreennaammee.  In
  41.      response to an ooppeenn the server  can  create  a  new  _s_e_r_v_i_c_e
  42.      _s_t_r_e_a_m  to  handle  subsequent   I/O  operations on the open
  43.      file.  This service stream is exactly like  a  pseudo-device
  44.      service   stream,  except  for  two  additional  operations,
  45.      PDEV_GET_ATTR (for ffssttaatt) and PDEV_SET_ATTR (for ffcchhoowwnn  and
  46.      ffcchhmmoodd).   Thus  the  server  ultimately has several request
  47.      response streams.  One naming  stream  and  several  service
  48.      streams, one for each open file.
  49.  
  50. SSEERRVVEERR IINNIITTIIAALLIIZZAATTIIOONN
  51.      The pseudo-file-system is activated by  opening  its  prefix
  52.      with the O_MASTER flag.  There must be a remote link for the
  53.      prefix or the open will fail.  (Use llnn  --rr  to  make  remote
  54.      links.)  The  prefix  can  be nested arbitrarily in the file
  55.      system.  The result of the open is a streamID for the naming
  56.      stream.   The IOC_PDEV_SET_BUF I/O Control has to be made on
  57.      this stream before the  request  response  protocol  can  be
  58.      used.   After this is done the naming stream is used exactly
  59.      like a pseudo-device service stream, except  that  different
  60.      (naming) operations appear in the request buffer.
  61.  
  62.  
  63.  
  64.  
  65. Sprite v.1.0       Printed:  December 8, 1989                   1
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. PFS                          Devices                          PFS
  73.  
  74.  
  75.  
  76.      Only one server  per  prefix  is  allowed.   If  the  prefix
  77.      corresponds  to  a regular part of the file system, or there
  78.      is already a user-level server for it, or there is no remote
  79.      link, then the open will fail.
  80.  
  81.      The prefix is exported throughout the  network,  unless  the
  82.      O_EXCLUSIVE  flag  is passed to ooppeenn.  The kernel takes care
  83.      of exporting the prefix; the server has to take  no  special
  84.      action.   The  existence  of  the  corresponding remote link
  85.      means that the kernel's name lookup algorithm will automati-
  86.      cally  find the prefix for the pseudo-file-system and locate
  87.      the server.
  88.  
  89. NNAAMMIINNGG OOPPEERRAATTIIOONNSS
  90.      The request messages in the  naming  stream  have  the  same
  91.      header  as  pseudo-device  requests, but different operation
  92.      codes and  operation-specific  parameters.   Note  that  the
  93.      magic number in the request header is PFS_REQUEST_MAGIC.
  94.  
  95.  
  96.           typedef struct {
  97.               unsigned int magic;       /* PDEV_REQUEST_MAGIC or PFS_REQUEST_MAGIC */
  98.               Pdev_Op operation;        /* What action is requested. */
  99.               int messageSize;          /* The complete size of the request header
  100.                                          * plus data, plus padding for alignment */
  101.               int requestSize;          /* Size of data following this header */
  102.               int replySize;            /* Max size of the reply data expected. */
  103.               int dataOffset;           /* Offset of data from start of header */
  104.           } Pdev_RequestHdr;
  105.  
  106.           typedef struct {
  107.               Pdev_RequestHdr hdr;      /* with PFS_REQUEST_MAGIC */
  108.               union {                   /* Additional parameters to the operation. */
  109.                   FsOpenArgs            open;
  110.                   FsOpenArgs            getAttr;
  111.                   FsOpenArgs            setAttr;
  112.                   FsMakeDeviceArgs      makeDevice;
  113.                   FsOpenArgs            makeDir;
  114.                   FsLookupArgs          remove;
  115.                   FsLookupArgs          removeDir;
  116.                   Fs2PathParams         rename;
  117.                   Fs2PathParams         hardLink;
  118.                   FsOpenArgs            symLink;
  119.               } param;
  120.               /*
  121.                * Data follows
  122.                */
  123.           } Pfs_Request;
  124.  
  125.  
  126.                The operation specific parameters are
  127.                described below along with the operations they are used with.
  128.  
  129.  
  130.  
  131. Sprite v.1.0       Printed:  December 8, 1989                   2
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. PFS                          Devices                          PFS
  139.  
  140.  
  141.  
  142.                These are defined in <dev/pfs.h>.
  143.                All the operation-specific parameters include
  144.                a pprreeffiixxIIDD that is a fileID for the starting point of the pathname
  145.                involved in the naming operation.  This corresponds to the
  146.                pseudo-file-system prefix if the original pathname was absolute,
  147.                or it corresponds to the process's current working directory
  148.                if the original pathname was relative.  In either case the
  149.                pathname given to the server is relative.
  150.                The fileID for the pseudo-file-system prefix has all zero fields,
  151.                unless it has been reset with the IOC_PFS_SET_ID call.
  152.                The fileID for the current directory is set when the
  153.                current directory is opened by the process.
  154.                This is described
  155.                in the section below on opening files.
  156.  
  157.                In the request-response protocol some data may follow each request
  158.                message header and operation-specific parameters.
  159.                This data is simply the pathname for the
  160.                following pseudo-file-system operations:
  161.                PFS_OPEN, PFS_GET_ATTR, PFS_MAKE_DEVICE, PFS_MAKE_DIR, PFS_REMOVE,
  162.                and PFS_REMOVE_DIR.  The other operations,
  163.                PFS_SET_ATTR, PFS_RENAME, and PFS_HARD_LINK have their
  164.                data areas described below.
  165.  
  166.                For all the operations the exact location and size of the data
  167.                is specified by the ddaattaaOOffffsseett and rreeqquueessttSSiizzee
  168.                fields in the request message header.
  169.  
  170. RREEPPLLYYIINNGG TTOO RREEQQUUEESSTTSS
  171.      Naming requests are replied to  just  like  regular  pseudo-
  172.      device  requests using IOC_PDEV_REPLY.  However, with naming
  173.      operations there is the possiblity of _p_a_t_h_n_a_m_e  _r_e_d_i_r_e_c_t_i_o_n.
  174.      If  the  pathname leaves the part of the file hierarchy con-
  175.      trolled by the pseudo-file-system server then it cannot com-
  176.      plete  the  naming  operation.   Instead, it must return the
  177.      remaining pathname as the reply data along with the  special
  178.      reply  status FS_LOOKUP_REDIRECT.  There are two formats for
  179.      the returned pathname:
  180.  
  181.           typedef struct FsRedirectInfo {
  182.               int                       prefixLength;/* The length of the prefix embedded in
  183.                                          * fileName.  This is used when a server hits
  184.                                          * a remote link and has to return a new file
  185.                                          * name plus an indication of a new prefix.
  186.                                          * Zero means no embedded prefix. */
  187.               char fileName[FS_MAX_PATH_NAME_LENGTH];
  188.                                         /* A new file name.  Returned
  189.                                          * from the server when its lookup is about
  190.                                          * to leave its domain. */
  191.           } FsRedirectInfo;
  192.  
  193.           typedef struct Fs2PathRedirectInfo {
  194.  
  195.  
  196.  
  197. Sprite v.1.0       Printed:  December 8, 1989                   3
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204. PFS                          Devices                          PFS
  205.  
  206.  
  207.  
  208.               int name1ErrorP;          /* TRUE if redirection applies
  209.                                          * to the first pathname, FALSE if the error
  210.                                          * applies to second pathname, or no error */
  211.               int                       prefixLength;
  212.               char fileName[FS_MAX_PATH_NAME_LENGTH];
  213.           } Fs2PathRedirectInfo;
  214.  
  215.      Pathname redirection can occur in three  cases:  a  symbolic
  216.      link  to  an absolute pathname is encountered, a remote link
  217.      is encountered, a ``..'' pathname component  is  encountered
  218.      that  would  take  the  pathname  out the top of the pseudo-
  219.      file-system.  If an absolute symbolic link or a remote  link
  220.      is  encountered  the  server should expand the link and then
  221.      return the new absolute pathname.  If it was a  remote  link
  222.      then the link contents identify a prefix.  Its length should
  223.      be set in the pprreeffiixxLLeennggtthh field.  If it  is  not  a  remote
  224.      link  then  the  pprreeffiixxLLeennggtthh field should be set to zero to
  225.      indicate no  prefix  information.   If  a  ``..''  component
  226.      corresponds  to  a  directory outside the pseudo-file-system
  227.      then the remaining pathname, including the offending  ``..''
  228.      component,  should  be  returned.   The  pprreeffiixxLLeennggtthh  field
  229.      should again be zero.
  230.  
  231.      The  PFS_RENAME  and  PFS_HARD_LINK  operations   may   have
  232.      redirection  occur  on either pathname.  FFss22PPaatthhRReeddiirreeccttIInnffoo
  233.      contains a field nnaammee11EErrrroorrPP that is used to  indicate  what
  234.      pathname  caused  a redirection.  Also, these operations may
  235.      be invoked even if the second pathname is not  part  of  the
  236.      pseudo-file-system.   This  situation  is  indicated  in the
  237.      operation-specific parameters by a pprreeffiixxIIDD22..ttyyppee  value  of
  238.      -1.   The  pseudo-file-system server is invoked in this case
  239.      to see if the  first  pathname  will  redirect  out  of  the
  240.      pseudo-file-system  and  perhaps end up with the same server
  241.      as the second pathname.  If redirection of  the  first  name
  242.      does  not  occur  and  the  second  pathname  is  not in the
  243.      pseudo-file-system then the  operation  cannot  succeed  and
  244.      FS_CROSS_DOMAIN_OPERATION should be returned.
  245.  
  246. PPFFSS__OOPPEENN
  247.           typedef struct FsOpenArgs {
  248.               Fs_FileID prefixID;       /* File ID from prefix handle */
  249.               Fs_FileID rootID;         /* File ID of root.
  250.                                          * Used to trap ".." past the root. */
  251.               int useFlags;             /* Flags defined in fs.h */
  252.               int permissions;          /* Permission bits for created files.  Already
  253.                                          * reflects per-process permission mask */
  254.               int type;                 /* Used to contrain open to a specific type */
  255.               int clientID;             /* Host ID of client doing the open */
  256.               Fs_UserIDs id;            /* User and group IDs */
  257.           } FsOpenArgs;
  258.  
  259.      The PFS_OPEN operation  is  used  to  open  a  file  in  the
  260.  
  261.  
  262.  
  263. Sprite v.1.0       Printed:  December 8, 1989                   4
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270. PFS                          Devices                          PFS
  271.  
  272.  
  273.  
  274.      pseudo-file-system.   The pprreeffiixxIIDD has been explained above.
  275.      The rroooottIIDD is unused for pseudo-file-systems.  The  uusseeFFllaaggss
  276.      are  those  passed to the ooppeenn system call.  The ppeerrmmiissssiioonnss
  277.      are used when creating new files and they already reflect  a
  278.      per-process  mode  mask.   The  ttyyppee is used to contrain the
  279.      open to succeed only for certain types of  files.   Possible
  280.      values  are  FS_FILE,  which  means  any type is acceptable,
  281.      FS_DIRECTORY, and FS_SYMBOLIC_LINK.   The  cclliieennttIIDD  is  the
  282.      Sprite hostID of the host the opening process is running on.
  283.      The iidd structure contains the user  and  group  IDs  of  the
  284.      opening process.
  285.  
  286.      When a file in the pseudo-file-system is opened  the  server
  287.      can  either  handle  all subsequent operations itself, or it
  288.      can open a regular file and pass this open file off  to  the
  289.      opening  process.  Both of these operations are done _i_n_s_t_e_a_d
  290.      of replying with IOC_PDEV_REPLY, which should only  be  used
  291.      for error replies.
  292.  
  293.      IOC_PFS_OPEN is used to create a new  pseudo-device  connec-
  294.      tion  for  the  file  being opened.  The input parameters of
  295.      this call are the  FsFileID  for  the  connection,  and  the
  296.      return  parametmer  of  the call is the open file descriptor
  297.      for the service stream.  The new service stream  is  exactly
  298.      like  a pseudo-device service stream, and all I/O operations
  299.      on the open file will be forwarded to the server using  this
  300.      service  stream.  The FsFileID is kept with the kernel state
  301.      for the open file.  If the open file is a process's  current
  302.      directory, then the FsFileID will be passed to the server as
  303.      the prefixID part of the naming parameters.
  304.  
  305.      IOC_PFS_PASS_STREAM is used to pass  an  already  open  file
  306.      back  to the opening process.  If this is done then the ker-
  307.      nel handles all subsequent operations on the open file.  The
  308.      pseudo-device  server  is  only  notified  when  the file is
  309.      closed (maybe, if that seems implementable.)
  310.  
  311. PPFFSS__GGEETT__AATTTTRR
  312.      The PFS_GET_ATTR operation is used to get the attributes  of
  313.      a file in the pseudo-file-system given its name.  It has the
  314.      same operation specific parameters as PFS_OPEN.   The  reply
  315.      data for this call should be an Fs_Attributes structure.
  316.  
  317. PPFFSS__SSEETT__AATTTTRR
  318.           typedef struct {
  319.               Fs_Attributes             attr;/* Attribute values */
  320.               int                       flags;/* Indicates which attributes to set */
  321.               int                       nameLength;/* Number of bytes in name */
  322.               char                      name[4];/* Actually larger */
  323.           } Pfs_SetAttrData;
  324.  
  325.      The PFS_SET_ATTR operation is used to set certain attributes
  326.  
  327.  
  328.  
  329. Sprite v.1.0       Printed:  December 8, 1989                   5
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. PFS                          Devices                          PFS
  337.  
  338.  
  339.  
  340.      of  a  file  in  the pseudo-file-system given its name.  The
  341.      operation specific parameters are the same as those for  the
  342.      PFS_OPEN   operation,   except  that  there  are  additional
  343.      paramaters passed as data following this header.  The format
  344.      of  the data is defined above as type PPffss__SSeettAAttttrrDDaattaa.  This
  345.      includes the new attributes for the file, and a flags  field
  346.      that  indicates which attributes to set.  The value of ffllaaggss
  347.      is  an  or'd  combination  of   FFSS__SSEETT__TTIIMMEESS,   FFSS__SSEETT__MMOODDEE,
  348.      FFSS__SSEETT__OOWWNNEERR, FFSS__SSEETT__FFIILLEE__TTYYPPEE, FFSS__SSEETT__DDEEVVIICCEE.
  349.  
  350. PPFFSS__MMAAKKEE__DDEEVVIICCEE
  351.           typedef struct FsMakeDeviceArgs {
  352.               Fs_FileID prefixID;       /* FileID of the prefix */
  353.               Fs_FileID rootID;         /* FileID of the root */
  354.               Fs_Device device;         /* Identifies the device */
  355.               int permissions;          /* Permissions already reflect per-process mask */
  356.               Fs_UserIDs id;
  357.               int clientID;
  358.           } FsMakeDeviceArgs;
  359.  
  360.      The PFS_MAKE_DEVICE operation is used to  create  a  special
  361.      device file in the pseudo-file-system.  The FFssMMaakkeeDDeevviicceeAArrggss
  362.      are similar to the FFssOOppeennAArrggss with some addition information
  363.      about the device.
  364.  
  365. PPFFSS__MMAAKKEE__DDIIRR
  366.      The PFS_MAKE_DIR operation is used to create a directory  in
  367.      the pseudo-file-system.  It uses the same operation specific
  368.      parameters as the PFS_OPEN operation.
  369.  
  370. PPFFSS__RREEMMOOVVEE
  371.           typedef struct FsLookupArgs {
  372.               Fs_FileID prefixID;       /* FileID of the prefix */
  373.               Fs_FileID rootID;         /* FileID of the root */
  374.               int useFlags;             /* not used */
  375.               Fs_UserIDs id;            /* User and group IDs */
  376.               int clientID;             /* Needed to expand $MACHINE */
  377.           } FsLookupArgs;
  378.  
  379.      The PFS_REMOVE operation is used to remove a file  from  the
  380.      pseudo-file-system.  Its operation specific parameters are a
  381.      simplified version of the parameters used for PFS_OPEN.
  382.  
  383. PPFFSS__RREEMMOOVVEE__DDIIRR
  384.      The PFS_REMOVE_DIR operation is used to remove  a  directory
  385.      from   the  pseudo-file-system.   The  server  should  guard
  386.      against removing non-empty directories.
  387.  
  388. PPFFSS__RREENNAAMMEE
  389.           typedef struct Fs2PathParams {
  390.               FsLookupArgs              lookup;/* Standard lookup arguments */
  391.               Fs_FileID                 prefixID2;/* Prefix ID of second pathname */
  392.  
  393.  
  394.  
  395. Sprite v.1.0       Printed:  December 8, 1989                   6
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402. PFS                          Devices                          PFS
  403.  
  404.  
  405.  
  406.           } Fs2PathParams;
  407.  
  408.      The PFS_RENAME operation is used to change  the  name  of  a
  409.      file  in  the  pseudo-file-system.   The  operation-specific
  410.      parameters include the prefixID  for  the  second  pathname.
  411.      The  data  following the header contains two null-terminated
  412.      relative pathnames in the following format:
  413.  
  414.           typedef struct Fs2PathData {
  415.               char                      path1[FS_MAX_PATH_NAME_LENGTH];
  416.               char                      path2[FS_MAX_PATH_NAME_LENGTH];
  417.           } Fs2PathData;
  418.  
  419. PPFFSS__HHAARRDD__LLIINNKK
  420.      The PFS_HARD_LINK operation is used to create  another  name
  421.      for  a  existing file in the pseudo-file-system.  It has the
  422.      same operation-specifc parameters and  data  format  as  the
  423.      PFS_RENAME command.
  424.  
  425. PPFFSS__SSYYMM__LLIINNKK
  426.      The PFS_SYM_LINK operation is used to create either a  symb-
  427.      lic  link  or  a remote link in the pseudo-file-system.  The
  428.      operation specific parameters are the same as for  PFS_OPEN,
  429.      and  the  data  contains  two  pathnames  in the FFss22PPaatthhDDaattaa
  430.      structure.  The first name is the name of the link file, and
  431.      the  second  name  is the name for the link value.  The ttyyppee
  432.      field in the FFssOOppeennAArrggss structure determines if it should be
  433.      a remote link or a regular symbolic link.
  434.  
  435. NNOOTTIICCEESS
  436.      IOC_PFS_PASS_STREAM is unimplemented, yet.
  437.  
  438.      PFS_SYM_LINK is unimplemented, yet.  Instead, symbolic links
  439.      are  created  by using PFS_OPEN and then PDEV_WRITE to write
  440.      the link value.
  441.  
  442.      A new operation, PFS_FS_INFO, will be added to  return  file
  443.      system information like free space.
  444.  
  445. SSEEEE AALLSSOO
  446.      Pfs, Pdev, pdev
  447.  
  448. KKEEYYWWOORRDDSS
  449.      server, pseudo-device
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461. Sprite v.1.0       Printed:  December 8, 1989                   7
  462.  
  463.  
  464.  
  465.